package lab02.test13;

public class Gymnastics extends ComputerAverage {
    //去掉一个最低分，去掉一个最高分，然后求平均分

    //属性

    //行为
    @Override
    double average(double[] scores) {
        double[] score = new double[scores.length];
        double max = scores[0];
        double min = scores[0];
        double sum = 0;

        for (int i = 0; i < scores.length; i++) {
            if (max < scores[i]) {
                max = scores[i];
            }
            if (min > scores[i]) {
                min = scores[i];
            }
        }

        for (int i = 0; i < scores.length - 2; i++) {
            if (scores[i] > min && scores[i] < max) {
                sum = sum + scores[i];
            }

        }

        return sum / 5;
    }
}
